<?php
include('inc_head.php');
$tag=$wu->request_string('tag');
if(!$tag) die('参数无效');
$id=$wu->request_int('id');
$rs=array('Name'=>'','Ordinal'=>'999','Url'=>'','Value'=>'','ParentID'=>$wu->request_int('pid'));
if($id){
	$rs=$db->fetch_row('select * from tgeneraldata where ID='.$id);
}
if($wu->request_string("act")=='save'){
	if($id){
		$db->update('tgeneraldata',"Name='".$wu->request_string('Name')."', ParentID=".$wu->request_int('ParentID').",Url='".$wu->request_string("Url")."', Ordinal=".$wu->request_int('Ordinal').", Value='".$wu->request_string('Value')."'","ID=$id");
		$wu->redirect('编辑成功','pages_list.php');
	}else{
		$db->insert('tgeneraldata','Name,ParentID,Ordinal,Value,ExTags,Url',"'".$wu->request_string('Name')."',".$wu->request_int('ParentID').", ".$wu->request_int('Ordinal').", '".$wu->request_string('Value')."','$tag','".$wu->request_string("Url")."'");
		$wu->redirect('新增成功','generaldata_list.php?tag='.$tag);
	}
}
?>

<form action="#" method="post" >
<fieldset>
    <legend>编辑数据<a href="generaldata_list.php?tag=<?php echo $tag; ?>">[列表管理]</a></h1>
<table cellpadding="0" cellspacing="0">名称</td><td><input type="text" name="Name" value="<?php echo $rs['Name'] ?>" /><span class="help-block">长度不超过15个汉字.</span></td></tr>
    <tr><td>上级</td><td><select name="ParentID"><?php echo $biz->get_generaltree($rs['ParentID'],'tgeneraldata',$tag); ?></select></td></tr>
    <tr><td>次序</td><td><input type="text" name="Ordinal" value="<?php echo $rs['Ordinal'] ?>" /></td></tr>
    <tr><td>地址</td><td><input type="text" name="Url" value="<?php echo $rs['Url'] ?>" /></td></tr>
    <tr><td>内容</td><td><textarea name="Value" cols="120" rows="15" class="editor"> <?php echo $rs['Value'] ?></textarea></td></tr>
    <tr><td>
            <input type="submit" value="保存" />
            <input type="reset" class="btn" value="重置" />
            <input type="hidden" name="act" value="save" />
        </td></tr>
</fieldset>
</form>
<?php
	include('inc_foot.php');
?>